<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        function lodeImg(src){
            return new Promise((resolve,reject)=>{
                //设置图片
                let img=new Image(200,200);
                img.src=src;
                
                //设置图片的加载
                img.onload=resolve(img);
                img.onerror=reject;

                document.body.append(img);
            });
        }
        lodeImg("./img/img1.jpg").then(value=>{value.style.border="solid 2px blue"},null)
        .catch(error=>console.log(error.message));
    </script>
</body>
</html>